<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">模板设置</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">

                    <div class="table-responsive table--no-card m-b-30">
                        <table id="table-template" class=" table-borderless table-striped table-earning ">
                            <thead>
                            <tr>
                                <th>模板目录</th>
                                <th>缩略图</th>
                                <th>默认</th>
                                <th class="w200px">工具</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if (sizeof ( $templates ) > 0) {
                                foreach($templates as $t){
                                    ?>
                                    <tr>
                                        <td class="tal"><?php echo $t;?></td>
                                        <td class="tac"><img src="/themes/<?php echo $t;?>/view.jpg" width="80px" height="80px" /></td>
                                        <td>
                                            <?php
                                            if($defTheme == $t){
                                                ?>
                                                <i class="fa fa-check-square text-success"></i>
                                                <?php
                                            }else{
                                                ?>
                                                <i class="fa fa-minus-square text-danger"></i>
                                                <?php
                                            }
                                            ?>
                                        </td>
                                        <td class="last tac">
                                            <button type="button" class="btn btn-primary btn-sm" onclick="setDefault('<?php echo $t; ?>')"  ></i>
                                                设为默认</button>
                                        </td>
                                    </tr>
                                    <?php
                                }
                            }
                            ?>
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        setTdVcenter();
    });
    function setTdVcenter() {
        $("#table-template").addClass("td-v-center");
    }
    var templatesize = <?php echo sizeof ( $templates ); ?>;
    function setDefault(template){
        $.get('index.php?r=admin/template/setDefault',{template:template},function(res){
            if(res==1){
                success("默认模板设置成功！")
                loadContent("index.php?r=admin/template/index");
            }
        });
    }
    function del(template){
        if(templatesize==1){
            danger('至少保留一个模板！');
        }else{
            confirm(function(){
                $.get('index.php?r=admin/template/delTemplate',{template:template},function(res){
                    if(res == 1){
                        window.location.reload();
                    }
                });
            },'确定删除模板？')
        }
    }
    function showedit(template){
        loadContent("index.php?r=admin/template/showedit&template="+template);
    }
</script>